/*
 * @lc app=leetcode.cn id=762 lang=cpp
 *
 * [762] 二进制表示中质数个计算置位
 */

// @lc code=start
class Solution
{
public:
  int countPrimeSetBits(int left, int right)
  {
    int p_bit = 0x50451456 << 1;
    int ans = 0;
    for (; left <= right; ++left)
      if (p_bit & (1 << BitCount(left)))
        ++ans;
    return ans;
  }

  int BitCount(int n)
  {
    int cnt = 0;
    for (; n != 0; n = n & (n - 1))
      ++cnt;
    return cnt;
  }
};
// @lc code=end
